<template>
  <common-table
    ref="table"
    :fetch-params="{ people_id: data.people_id }"
    :fetch="getDataAsync"
    :columns="columns"
    :show-toolbar="false"
    @vue:mounted="() => $refs.table.load()"
    style="height: 100%; width: 100%"
  >
    <template #index="{ index }">
      <span>{{ index + 1 }}</span>
    </template>
  </common-table>
</template>

<script>
import CommonTable from '@gis/lib/components/vex-table/index.vue';
export default {
  name: 'location-table',
  components: { CommonTable },
  props: {
    data: { type: Object, default: () => ({}) },
  },
  data() {
    return {
      columns: [
        {
          title: '手环设备号',
          dataIndex: 'imei',
          ellipsis: true,
        },
        {
          title: '测量时间',
          dataIndex: 'time_begin',
          ellipsis: true,
        },
        {
          title: '预警阈值上限',
          dataIndex: 'theshold_heartrate_h',
          ellipsis: true,
        },
        {
          title: '预警阈值下限',
          dataIndex: 'theshold_heartrate_l',
          ellipsis: true,
        },
        {
          title: '心率',
          dataIndex: 'heartrate',
          ellipsis: true,
        },
      ],
    };
  },
  methods: {
    async getDataAsync(params) {
      const res = await this.$axios.get('/xw-microservice/xw-actual-data/v3/bracelet/heartrate/page', {
        params,
      });
      const data = res.data || {};
      return { data: data.list, total: data.count };
    },
  },
};
</script>

<style scoped></style>
